// 翻转对数量
// 测试链接 : https://leetcode.cn/problems/reverse-pairs/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.io.PrintWriter;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class ReversePairs {
    public static int MAX = 50000;
    public static int arr[] = new int[MAX];
    public static int n;

    public static int[] help = new int[MAX];  //辅助数组

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        while (in.nextToken() != StreamTokenizer.TT_EOF) {
            n = (int) in.nval;
            for(int i = 0; i<n ; ++i) {
                in.nextToken();
                arr[i] = (int) in.nval;
            }
            out.println(reversePairs(0,n-1));
        }
        out.println();
        out.close();
        br.close();
    }

    public static int reversePairs(int l, int r ) {
        if(l==r) {
            return 0;
        }
        int m = l +((r-l) >> 1);

        return reversePairs(l,m) + reversePairs(m+1,r) + merge(l,m,r);
    }

    public static int merge(int l, int m, int r) {
        int ans = 0;
        // 1   2    3    1    3
        //          i         j
        for(int i=m,j=r,sum = 0; j>m; --j) {
            while(i>=l && (long)arr[i] >  (long)arr[j]*2) {
                sum++;
                i--;
            }
            ans += sum;
        }

        //排序
        int a=l,b=m+1;
        int index = l;
        while(a<=m && b<=r) {
            help[index++] = arr[a] <= arr[b] ? arr[a++] : arr[b++];
        }
        while (a<=m) {
            help[index++] = arr[a++];
        }
        while (b<=r) {
            help[index++] = arr[b++];
        }
        index = l;
        while (index <= r){
            arr[index] = help[index];
            index++;
        }
        return ans;
    }
}
